package com.example.orderservice.demos.web;

import org.apache.commons.lang.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;
import java.util.UUID;

/**
 * @Classname OrderServiceImpl
 * @Description
 * @Author caozhenhao001
 * @Date 2024/3/20
 * @Version
 */
@Service
public class OrderServiceImpl implements OrderService{
    @Autowired
    UserFeignClient userFeignClient;
    @Override
    public Order createOrder(String userId) {
        User user = userFeignClient.getUserById(userId);
        Order order = new Order();
        order.setId(UUID.randomUUID().toString());
        order.setCreateBy(user.getName());
        Random random = new Random();
        order.setProductId(random.nextInt(10000000) + 10000000 + "");
        return order;
    }
}
